package com.service.impl;

import com.mapper.RoomMapper;
import com.pojo.Room;
import com.service.RoomService;
import com.vo.RoomVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    public boolean addRoom(Room room) {
        int res = roomMapper.addRoom(room);
        if (res>0){
            return true;
        }else{
            return false;
        }

    }

    public boolean updateRoomByRid(Room room) {
        int res = roomMapper.updateRoomByRid(room);
        if (res>0){
            return true;
        }else {
            return false;
        }

    }

    public int deleteRoomByRid(Integer id) {
        return roomMapper.deleteRoomByRid(id);
    }

    public Room getRoomByRid(Integer id) {
        return roomMapper.getRoomByRid(id);
    }

    public List<Room> getRoomList(RoomVO roomVO,int pageSize) {
        if(roomVO!=null){
            roomVO.setPageIndex((roomVO.getPageIndex()-1)*pageSize);
        }


        return roomMapper.getRoomList(roomVO,pageSize);
    }

    public int getRoomCount(RoomVO roomVO) {
        return roomMapper.getRoomCount(roomVO);
    }
}
